<template>
    <div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td>账号</td>
                    <td>电话</td>
                    <td>密码</td>
                </tr>
                <tr v-for="a in as.row" :key="a.id">
                    <td>{{ a.name }}</td>
                    <td>{{ a.zname }}</td>
                    <td>{{ a.tel }}</td>
                    <td>***</td>
                </tr>
            </tbody>
        </table>
    </div>
    <div>
        <span>当前{{ cs.pagesize }}页</span>--
        <span>共{{ as.pagecount }}条</span>--
        <span>当前{{ cs.pageindex }}/{{ as.sizecount }}页</span>
        <input type="button" value="首页" @click="fy(1)">
        <input type="button" value="上一页" @click="fy(cs.pageindex - 1)">
        <input type="button" value="下一页" @click="fy(cs.pageindex + 1)">
        <input type="button" value="尾页" @click="fy(as.sizecount)">
    </div>

</template>

<script setup lang="ts">
import axios from 'axios';
import { ref, reactive, onMounted } from "vue";
import moment from 'moment';
import { useStore } from '@/stores/ioi';
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();
const a = useStore();


let cs: any = reactive(
    {
        pageindex: 1,
        pagesize: 2,
    }
)
let as: any = reactive(
    {
        pagecount: 0,
        sizecount: 0,
        row: []
    }
)
const fy = (f: any) => {
    if (f < 1) {
        cs.pageindex = 1;
        return;
    }
    if (f > as.sizecount) {
        cs.pageindex = as.sizecount;
        return;
    }
    cs.pageindex = f;
    show();
}
onMounted(() => {
    if (a.info.id) {
        show();
    } else {
        router.push("/Login")
    }

})
const show = () => {
    axios({
        url: 'https://localhost:7235/api/Emp/showlogin',
        method: 'get',
        params: cs
    })
        .then(res => {
            console.log(res);
            as.pagecount = res.data.pagecount;
            as.sizecount = res.data.sizecount;
            as.row = res.data.row;
        })
        .catch(err => {
            console.log(err);

        })
}
</script>

<style scoped></style>